use "/Users/hututu/Desktop/data.dta",clear
xtset stkcd year
egen city1=group(city)
egen H=group(Industrycode)
winsor2 Age Debtass ROA Pcc Size Top10,replace cuts(1 99)

*TABLE 1 Descriptive statistics of the main variables.
asdoc sum GWL Age Debtass ROA Pcc Size Top10 Dual


*TABLE 2 The results of baseline regression
asdoc reghdfe GWL Digital Age Debtass ROA Pcc Size Top10 Dual,absorb(stkcd year) cluster(stkcd) nest replace


*TABLE 3 Instrumental variable approach
asdoc ivreghdfe GWL Age Debtass ROA Pcc Size Top10 Dual (Digital=IV1 IV2),absorb(stkcd year) cluster(stkcd) first endog(Digital) nest replace


*TABLE 4 Other robustness test
//Changing the Dependent Variable
asdoc reghdfe GW Digital Age Debtass ROA Pcc Size Top10 Dual,absorb(stkcd year) cluster(stkcd) nest replace
//Changing the Clustering Method
asdoc reghdfe GWL Digital Age Debtass ROA Pcc Size Top10 Dual,absorb(stkcd year) cluster(H) nest append
//Propensity Score Matching (PSM) Method
forvalues i = 2015/2020{
use "/Users/hututu/Desktop/data.dta", clear
egen Mean_Digital=mean(Digital)
gen T=0
replace T=1 if Digital>=Mean_Digital
 keep if year==`i'
 set seed 20210415
 gen tmp=runiform()
 sort tmp
 psmatch2 T Age Debtass ROA Pcc Size Top10 Dual,out(GWL) logit neighbor(3) common ate  
 drop if _weight==.
 save psmdid_`i',replace
}

use psmdid_2015,clear
forvalues i = 2015/2020{
 append using psmdid_`i'
}

asdoc reghdfe GWL Digital Age Debtass ROA Pcc Size Top10 Dual,absorb(stkcd year) cluster(stkcd) nest append


*TABLE 5 Mechanism analysis
use "/Users/hututu/Desktop/data.dta",clear
xtset stkcd year
winsor2 Age Debtass ROA Pcc Size Top10,replace cuts(1 99)
//R&D innovation investment
asdoc reghdfe Rd Digital Age Debtass ROA Pcc Size Top10 Dual,absorb(stkcd year) cluster(stkcd) nest replace
//Internal governance capability
asdoc reghdfe Gover Digital Age Debtass ROA Pcc Size Top10 Dual,absorb(stkcd year) cluster(stkcd) nest append
//External supervision level
asdoc reghdfe Asy Digital Age Debtass ROA Pcc Size Top10 Dual,absorb(stkcd year) cluster(stkcd) nest append


*TABLE 6 Heterogeneity analysis
//Analysis of corporate ownership heterogeneity
asdoc reghdfe GWL Digital Age Debtass ROA Pcc Size Top10 Dual if SOE==0,absorb(stkcd year) cluster(stkcd) nest replace
asdoc reghdfe GWL Digital Age Debtass ROA Pcc Size Top10 Dual if SOE==1,absorb(stkcd year) cluster(stkcd) nest append
//Analysis of corporate size heterogeneity
bysort year: egen Mean_Size=median(Size)
gen Large=0
replace Large=1 if Size>=Mean_Size
asdoc reghdfe GWL Digital Age Debtass ROA Pcc Size Top10 Dual if Large==0,absorb(stkcd year) cluster(stkcd) nest append
asdoc reghdfe GWL Digital Age Debtass ROA Pcc Size Top10 Dual if Large==1,absorb(stkcd year) cluster(stkcd) nest append
//Analysis of corporate top management's environmental awareness heterogeneity
use "/Users/hututu/Desktop/data.dta",clear
xtset stkcd year
winsor2 Age Debtass ROA Pcc Size Top10,replace cuts(1 99)
merge m:1 stkcd year using "/Users/hututu/Desktop/Top Management Environmental Awareness.dta"
keep if _merge==3
bysort year: egen Mean_GK=median(GK)
gen HEA=0
replace HEA=1 if GK>=Mean_GK
asdoc reghdfe GWL Digital Age Debtass ROA Pcc Size Top10 Dual if HEA==0,absorb(stkcd year) cluster(stkcd) nest replace
asdoc reghdfe GWL Digital Age Debtass ROA Pcc Size Top10 Dual if HEA==1,absorb(stkcd year) cluster(stkcd) nest append
//Analysis of regional environmental regulatory level heterogeneity
use "/Users/hututu/Desktop/data.dta",clear
xtset stkcd year
winsor2 Age Debtass ROA Pcc Size Top10,replace cuts(1 99)
merge m:1 PROVINCE year using "/Users/hututu/Desktop/The environmental regulation intensity.dta"
keep if _merge==3
bysort year: egen Mean_ER=median(ER)
gen HER=0
replace HER=1 if ER>=Mean_ER
asdoc reghdfe GWL Digital Age Debtass ROA Pcc Size Top10 Dual if HER==0,absorb(stkcd year) cluster(stkcd) nest replace
asdoc reghdfe GWL Digital Age Debtass ROA Pcc Size Top10 Dual if HER==1,absorb(stkcd year) cluster(stkcd) nest append
